package com.shushan.home.bean;

import com.android.net.bean.NetBaseBean;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;

/**
 * @ClassName: ExtractVipBean
 * @Desciption: //TODO
 * @author: yichaohua
 * @date: 2018-11-01
 */
public class ExtractVipBean extends NetBaseBean {

    private final static String ALL_TYPE_ID = "all";
    private final static String CHINESE_TYPE_ID = "yuwen";
    private final static String MATH_TYPE_ID = "shuxue";
    private final static String ENGLISH_TYPE_ID = "yingyu";

    private HashMap<String,OpenExtractVipBean> extractVipBeanHashMap = new HashMap<String,OpenExtractVipBean>();

    @Override
    public void initByJson(JSONObject jsonObject) throws JSONException {
        JSONObject allJson = jsonObject.optJSONObject(ALL_TYPE_ID);
        if(allJson != null){
            OpenExtractVipBean openExtractVipBean = new OpenExtractVipBean();
            openExtractVipBean.initByJson(allJson);
            extractVipBeanHashMap.put(ALL_TYPE_ID,openExtractVipBean);
        }

        JSONObject chineseJson = jsonObject.optJSONObject(CHINESE_TYPE_ID);
        if(chineseJson != null){
            OpenExtractVipBean openExtractVipBean = new OpenExtractVipBean();
            openExtractVipBean.initByJson(chineseJson);
            extractVipBeanHashMap.put(CHINESE_TYPE_ID,openExtractVipBean);
        }

        JSONObject mathJson = jsonObject.optJSONObject(MATH_TYPE_ID);
        if(mathJson != null){
            OpenExtractVipBean openExtractVipBean = new OpenExtractVipBean();
            openExtractVipBean.initByJson(mathJson);
            extractVipBeanHashMap.put(MATH_TYPE_ID,openExtractVipBean);
        }

        JSONObject englishJson = jsonObject.optJSONObject(ENGLISH_TYPE_ID);
        if(englishJson != null){
            OpenExtractVipBean openExtractVipBean = new OpenExtractVipBean();
            openExtractVipBean.initByJson(englishJson);
            extractVipBeanHashMap.put(ENGLISH_TYPE_ID,openExtractVipBean);
        }
    }

    public OpenExtractVipBean getALlVipBean(){
        return extractVipBeanHashMap.get(ALL_TYPE_ID);
    }

    public OpenExtractVipBean getChineseVipBean(){
        return extractVipBeanHashMap.get(CHINESE_TYPE_ID);
    }

    public OpenExtractVipBean getMathVipBean(){
        return extractVipBeanHashMap.get(MATH_TYPE_ID);
    }

    public OpenExtractVipBean getEnglishVipBean(){
        return extractVipBeanHashMap.get(ENGLISH_TYPE_ID);
    }
}
